{% extends '_base.html' %}

{% block nav %} /search {% endblock %}

{% block meta %}
    <meta property="og:ad" content="true" />
    <meta property="og:type" content="webpage" />
    <meta property="og:url" content="{{ __url__ }}" />
{% endblock %}

{% block title %}
	{{ _('Search') }}
	{% if q %} {{ q }} {% endif %}
{% endblock %}

{% block content %}
    <h4>{{ _('Search result') }}</h4>
    <div class="x-search-form">
        <form action="/search" method="get" class="uk-form uk-form-stacked uk-margin-bottom" style="width:100%">
            <div class="uk-form-controls">
				<div class="uk-form-icon" style="width:100%">
					<i class="uk-icon-search"></i>
					<input name="q" value="{{ q }}" type="text" maxlength="50" placeholder="keyword" style="width:100%">
				</div>
            </div>
        </form>
    </div>

    <div class="x-search-results">
        {% if results == null or results.size() == 0 %}
            <div class="uk-alert uk-alert-warning x-search-no-result">
                <h4>{{ _('~search-not-found-error') }}</h4>
                <p>{{ _('~search-not-found-message') }}</p>
            </div>
        {% else %}
            {% for r in results %}
                <div class="x-search-result">
                    <h4><a href="{{ r.url }}" target="_blank">{{ r.name|raw }}</a></h4>
                    <p class="x-search-result-content">{{ r.content|raw }}</p>
                </div>
            {% endfor %}
            {{ pagination("?q=" + q|url + "&page=", page) }}
        {% endif %}
    </div>

{% endblock %}
